home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 726-750 / 742 / icalc / scripts / gl.ic < prev    next >
Text File  |  1995-03-18  |  689b  |  33 lines

  1. # 10-pt Gauss-Legendre integration
  2. # This is an 'open' method, i.e. it doesn't evaluate the function at
  3. # the integration limits, so the function may be undefined there.
  4. # However, user should consider existence of integral in such a case.
  5. #
  6. # nb: routines assume array base is 1
  7. # mws, February, 1992.
  8.  
  9. array glx[5] = {
  10.     .1488743389, .4333953941, .6794095682, .8650633666, .9739065285
  11. }
  12.  
  13. array glw[5] = {
  14.     .2955242247, .2692667193, .2190863625, .1494513491, .0666713443
  15. }
  16.  
  17. func gl(~f,a,b) = {
  18.     local xm, xr, ss, j, dx, tmp
  19.     xm = 0.5*(b+a)
  20.     xr = 0.5*(b-a)
  21.     ss = 0
  22.     for (j = 1; j <= 5; j += 1) {
  23.         dx = xr*glx[j]
  24.         x = xm+dx
  25.         tmp = f
  26.         x = xm-dx
  27.         tmp += f
  28.         ss += glw[j]*tmp
  29.     }
  30.     xr*ss
  31. }
  32.  
  33.